﻿using mozhi.smarterp.Finance.AccountsPayables.PurchasePayables.Links;
using mozhi.smarterp.Finance.AccountsPayables.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace mozhi.smarterp.Finance.AccountsPayables.PurchasePayables
{
    public class PurchasePayableReceiptAppService : FinanceAppService, IPurchasePayableReceiptAppService
    {
        private IPurchasePayableReceiptRepository _repository;

        public PurchasePayableReceiptAppService(IPurchasePayableReceiptRepository repository)
        {
            _repository = repository;
        }

        public async Task<int> GetCountAsync(Guid? payableId, Guid? payableItemId, Guid? receiptId, Guid? receiptItemId)
        {
             var count = await _repository.GetCountAsync(payableId , payableItemId , receiptId , receiptItemId);

            return count;
        }

        public async Task<List<PurchasePayableReceiptDto>> GetListAsync(Guid? payableId, Guid? payableItemId, Guid? receiptId, Guid? receiptItemId)
        {
            var links = await _repository.GetListAsync(payableId, payableItemId, receiptId, receiptItemId);

            var result = ObjectMapper.Map<List<PurchasePayableReceipt>, List<PurchasePayableReceiptDto>>(links);

            return result;
        }
    }
}
